const fs = require('fs');
// 生成从minNum到maxNum的随机数
function randomNum(minNum, maxNum) {
  switch (arguments.length) {
    case 1:
      return parseInt(Math.random() * minNum + 1, 10);
    case 2:
      return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
    default:
      return 1;
  }
}

async function main() {
  let data = [];
  for (let index = 0; index < 10000; index++) {
    const userid = randomNum(1000, 1068); // 不超过1068
    const itemid = randomNum(400, 2689); // 不超过2689
    const rating = randomNum(1, 8);
    data.push(`${userid}\t${itemid}\t${rating}`);
  }
  fs.writeFileSync('data-1.txt', data.join('\n'));
}

main();
